Welcome to HTML5 Input Element
– Attributes for the Input Tag. After watching this video, you will be able to describe the attributes of
the HTML5 input elements, explain the different input type attributes, such
as tel, email, datetime, number, range, and color, and importance of implementing
validation fallback. The input type="color" / attribute
allows the user to select a color. The dialog varies depending on the browser. Some browsers don’t support this input type. In non-supporting browsers, this input
type is displayed as a regular text input field into which the user might
type a valid color name or color code. The input type="date" attribute is a date
control (year, month, day) with no time zone. The example shows the input type="date"
field as it is seen in Google Chrome. The input dialog varies from browser to browser. The datetime-local attribute provides
input for a date and time (year, month, day, hour, minute, AM/PM) with no time zone. The datetime-local input field is displayed as a
drop-down calendar in the Google Chrome browser. The time can be typed or entered
using the spinner control. The input type="email" attribute is
displayed as a regular text input field. It provides feedback when the input
does not follow the email format. The input type="number"
takes a numeric value as input. You can optionally specify the minimum,
maximum values, step size, etc. The example shows the number
selector in the Chrome browser. Only the numbers between 5 and the
10 are available for selection. The input type="range"
takes a numeric range as input. The example shows the number
selector in the Chrome browser. Only the numbers in the range of the minimum and the maximum are available for selection. The range attribute displays a slider with a range of values between the minimum and maximum. Only the slider itself is shown. Additional JavaScript code is needed in order to display the value of the slider. The differences between input type="search" /
and input type="text" / are mostly in style. WebKit-based browsers return a history
of recently searched text strings. The search input field on the
Safari browser has rounded corners. The input type="tel" pattern="[parameters]"
attribute expects a telephone number as input. On its own, the input type="tel" provides nothing more than a text
entry field in the browsers. It does not enforce numeric only input since many telephone numbers include other
characters, such as the plus sign and hyphens. You need to supply your own pattern matcher if you
want the browser to validate the telephone number. The URL attribute is used
to validate that the user typed in a properly formatted URL or web address. The input list="some_list"
uses the datalist feature. Not to be confused with the select element. The datalist options are only suggestions. Useful for auto-complete functionality. You can fill the list by nesting <option>
elements inside the datalist tag. These options are the types of
fruits listed in the drop-down list. Placeholder text is used to provide hints
of what the input text format looks like. The placeholder fills the input text field with
the example values in a lighter shade of text. The form does not submit the placeholder text
value if the input text is not overwritten. The required attribute implies
that some text must be typed. The requirement to type some input applies
even if the field contains placeholder text. What happens if browser-based validation is
not supported for these input attributes? There are several options to performing validation in browsers that do not support
all HTML5 input attributes. You can use JavaScript and JQuery libraries. You can assume that more browsers
will support these features over time, and leave all final validation
to server-side processing. You can code client-side validation
that is attached to the form submit event handler to validate all the fields
on the form when the form is submitted. In this video, you learned: Common attributes of the input tag and how to implement validation fallback.